import { defineStore } from "pinia";
import systemTheme from '@/utils/systemTheme'


export const useTheme = defineStore({
	id: "theme",
	state: () => ({
		themeType: uni.getStorageSync('theme') ?? '',
		systemTheme: systemTheme
	}),

	getters: {
		getThemeType() : any {
			console.log(this.themeType);
			return this.themeType;
		},
	},
	actions: {
		setTheme(e : string) {
			// 存储到本地
			uni.setStorageSync('theme', e);
			this.themeType = e
			plus.runtime.restart();
		}
	},
});

export const theme = () => {
	const theme = useTheme()
	return theme.themeType
}